package com.sxf.common.exceptions;


import com.sxf.common.enums.SystemCommonCode;
import com.sxf.consts.ISystemCode;

/**
 * 业务异常.
 * @author Author
 * @version 1.0
 * @title BusinessException
 * @description 业务异常.
 * @date 2016年11月8日
 */
public class BusinessException extends BaseRuntimeException {
    /**
     * 错误代码
     */
    private Integer errorCode;

    private static final long serialVersionUID = 7805981291350841911L;

    public BusinessException() {
        super("Business Exception.");
    }

    public BusinessException(String errMsg) {
        super(errMsg);
    }

    public BusinessException(int errorCode, String errMsg) {
        super(errMsg);
        this.errorCode = errorCode;
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }
    
    public BusinessException(ISystemCode systemCode, Object... params) {
    	super(systemCode.getMessage(params));
    	this.errorCode = systemCode.getCode();
    }

    @Override
    public int getErrorCode() {
        if (errorCode == null) {
            return SystemCommonCode.BUSINESS_ERR;
        }
        return errorCode;
    }


}
